<%@page import="cn.egame.common.util.Utils"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@page import="cn.egame.ext.op.OperationActivityInfo"%>
<%@page import="cn.egame.ext.EnumTypeExt.OperationActivityRecordType"%>
<%@page import="cn.egame.ext.EnumTypeExt.OperationActivityPosition"%>
<%@page import="cn.egame.interfaces.fl.FileUsedType"%> 
<%@page import="com.egame.manage.biz.utils.ConstVar"%>
<%@page import="cn.egame.interfaces.pu.AppParameter"%>


<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<% 
	String urlString = request.getContextPath() + "/store/game/topic/set/edit.do"; 
%>
<link type="text/css" rel="stylesheet" href="<%=request.getContextPath()%>/css/main.css"  />
<script type="text/javascript" src="<%=request.getContextPath()%>/js/jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/js/ajaxfileupload.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/js/My97DatePicker/WdatePicker.js"></script>
<script type="text/javascript">
	function savePic(id,name,width,height,type){
		//检查图片
		var filepath = document.getElementById(id).value;
		if(filepath==""){
		    alert("请选择上传的图片！");
		    return;
		}else {
			var extname = filepath.substring(filepath.lastIndexOf(".")+1,filepath.length);
			extname = extname.toLowerCase();
			if(extname!= "jpg"){
	            alert("图片类型必须是.jpg格式");
	            return;
			}
		}
		var domain="<%=request.getContextPath() + "/store/app/image/width/height.do?name=" %>" + name +"&width=" + width + "&height=" + height + "&type=" + type;
		jQuery.ajaxFileUpload({
			url:domain,
			secureuri:false,
			fileElementId:id,
			dataType:"text",
			success: function (data) {		
				data = data.split(">")[1].split("<")[0];
				if(data.split(",")[0] == '-1'){
					alert("您上传的图片尺寸不符合规格!");
					return false;
				}else{
					document.getElementById("picId").value =  data.split(",")[0];
					document.getElementById("adimage").src = data.split(",")[1];
					return true;
				}
	          }
		});
		return true;
	}

	function formSubmit(){
		var filepath = $("#uploadFile").val();
		var adPosi = $("#adPosi").val();
		var td = $("#form1").find("td[name='notnone']");
		var isSubmit = true;
		for(var i = 0; i<td.length; i++){
			if($(td[i]).find("input[type='text']").val() == "" || ($(td[i]).find("select")[0] && $(td[i]).find("option:selected").val() == 0)||($(td[i]).find("input[type='hidden']").val() == "")){
				$(td[i]).find("span").remove();
				$(td[i]).append("<span class='page_tip'>*必填</span>");
				isSubmit = false;
				return;
			}else{
				$(td[i]).find("span").remove();
			}
		}
		
		if(isSubmit){
			document.getElementById("form1").submit();
		}else{
			return;
		}
	}
</script>
<title>活动编辑页面</title>
</head>
<body>
<% 
	String filepath = "";
	if(request.getAttribute("filepath")!=null){
		filepath = (String)request.getAttribute("filepath");
	}

%>
<div class="matter_box">
	<h3 class="nopoint"><strong>彩蛋>游戏>专题>编辑</strong></h3>
	<div class="mt10 pt10 clearfix">
<form action=<%=urlString %> method="post" enctype="multipart/form-data" id="form1">	
		<table class="table2">
		<%
			if(request.getAttribute("bean")!=null){
				AppParameter bean = (AppParameter)request.getAttribute("bean");			
		%>
			<tr>
				<td>专题名称</td>
				<td name="notnone">
					<input type=hidden name=id value=<%=bean.getId() %> > 
					<input type=text name=name value=<%=bean.getName() %>>
				</td>
			</tr>
			<tr>
				<td>专题推荐语</td>
				<td name="notnone">
					<input type=text name=remark value=<%=bean.getRemark()%>>
				</td>
			</tr>
			<tr>
				<td>专题图片</td>
				<td name="notnone">
					<input type="hidden" name="file_type" id="file_type" value="<%=FileUsedType.FILE %>">
					<input type=hidden name=picId id=picId value="<%=bean.getPicId() %>">
					<input type="file" name=pic id="uploadFile" value="">
					<a id="upload" href="javascript:savePic('uploadFile','pic',468,144,<%=FileUsedType.FILE %>)"  class="btn2" >上传</a>
												
					<span style="color: #ff0000;margin-left: 15px;" id="imgSpan">图片格式JPG。尺寸为：468*144</span><p>	
					<img  id="adimage"  src="<%=filepath %>" width="200" height="100"> 
				</td>
			</tr>
			<tr>
				<td>开始时间</td>
				<td name="notnone">
				<% 
					String time = "";
					if(bean.getBeginTime() != null){
						time = Utils.toDateString(bean.getBeginTime(),"yyyy-MM-dd hh:mm:ss");
					}					
				%>
					<input type=text name=beginString onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})" class="Wdate" value="<%=time %>"></td>
			</tr>
			<tr>
				<td>结束时间</td>
				<td name="notnone">
				<% 
				String endtime = "";
				if(bean.getEndTime() != null){
					endtime = Utils.toDateString(bean.getEndTime(),"yyyy-MM-dd HH:mm:ss");
				}	
				%>
					<input type=text name=endString onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})" class="Wdate" value="<%=endtime %>"></td>
			</tr>
			<tr>
				<td colspan="2"><input type="button" value="提交" class="btn3" onclick="formSubmit()"></td>
			</tr>
		<%
			}
		%>
		</table>
	</form>
</div>
</div>
</body>
</html>